﻿using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using OfficeOpenXml.ConditionalFormatting;
using VOL.Core.Utilities;
using VOL.SmartMecial.Dtos;
using VOL.SmartMecial.IServices.EquipmentManage;

namespace VOL.WebApi.Controllers.SmartMecial
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EquipmentSomeThingController : ControllerBase
    {
        IEquipmentServices services;

        public EquipmentSomeThingController(IEquipmentServices services)
        {
            this.services = services;
        }
        /// <summary>
        /// 显示设备登记
        /// </summary>
        /// <param name="NursingUnitId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<WebResponseContent> ShowEquipment(int? nursingUnitId)
        {
            var result = await services.ShowEquipment(nursingUnitId);
            var webResponseContent = WebResponseContent.Instance.OK(null, result);
            return webResponseContent;
        }

        /// <summary>
        /// 科室树
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<WebResponseContent> ShowTree()
        {
            var result = await services.ShowTree();
            var webResponseContent = WebResponseContent.Instance.OK(null, result);
            return webResponseContent;
        }
        /// <summary>
        /// 添加设备登记
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebResponseContent> AddEquipment([FromBody]Entity.DomainModels.Equipment equipment)
        {
            var rseult = await services.AddEquipment(equipment);
            var webResponseContent = WebResponseContent.Instance.OK(null, rseult);
            return webResponseContent;
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebResponseContent>  DelEquipment(int id)
        {
            var rseult = await services.DelEquipment(id);
            var webResponseContent = WebResponseContent.Instance.OK(null, rseult);
            return webResponseContent;
        }
        /// <summary>
        ///回显
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<WebResponseContent> GetEquipmentById(int id)
        {
            var rseult = await services.GetEquipmentById(id);
            var webResponseContent = WebResponseContent.Instance.OK(null, rseult);
            return webResponseContent;
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebResponseContent> UpdateEquipment([FromBody]Entity.DomainModels.Equipment equipment)
        {
            var rseult = await services.UpdateEquipment(equipment);
            var webResponseContent = WebResponseContent.Instance.OK(null, rseult);
            return webResponseContent;
        }
    }
}
